//
//  AXHomePtsfxIFeatureCell.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/11/2.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "AXHomePtsfxIFeatureCell.h"
#import "UIView+SDAutoLayout.h"
#import "ZXCategories.h"
#import "UITableView+SDAutoTableViewCellHeight.h"


@implementation AXHomePtsfxIFeatureCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self creatView];
        [self setlayout];
    }
    return self;
}


- (void)creatView {
    /** 产品图片 */
    self.productImageView = [[UIImageView alloc]init];
    self.productImageView.contentMode =UIViewContentModeScaleAspectFill;
    self.productImageView.clipsToBounds=YES;//
    [self.contentView addSubview:self.productImageView];
    /** 产品名字 */
    self.nameLabel = [[UILabel alloc]init];
    self.nameLabel.textColor = COLOR_Gray;
    self.nameLabel.numberOfLines = 2;
    self.nameLabel.font = FONT_FOURTEEN;;
    [self.contentView addSubview:self.nameLabel];
    
    /** 星星 */
    self.starAppraiseView = [[ ZXSampleStarAppraiseView alloc]init];
    self.starAppraiseView.score = 5;
    [self.contentView addSubview:self.starAppraiseView];
    /** 产品销量 */
    self.saleLabel = [[UILabel alloc]init];
    self.saleLabel.text = @"月销量444";
    self.saleLabel.font = FONT_FOURTEEN;
    self.saleLabel.textColor = COLOR_DIV;
    [self.contentView addSubview:self.saleLabel];
    /** 绿色食品 */
    self.greenFoodButton = [[UIButton alloc]init];
    self.greenFoodButton.titleLabel.font = FONT_FOURTEEN;
    self.greenFoodButton.backgroundColor = COLOR_GREEN;
    [self.greenFoodButton setTitle:@"绿色食品" forState:UIControlStateNormal];
    [self.greenFoodButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.contentView addSubview:self.greenFoodButton];
    
    
    
    
}

- (void)setlayout {
    
    self.greenFoodButton.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.nameLabel, 10)
    .widthIs(80)
    .heightIs(20);
    
    self.productImageView.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 10)
    .widthIs(120)
    .heightIs(100);
    
    self.nameLabel.sd_layout
    .leftSpaceToView(self.productImageView, 10)
    .topSpaceToView(self.contentView, 10)
    .rightSpaceToView(self.greenFoodButton, 10)
    .autoHeightRatio(0)
    .minHeightIs(40);
    
    self.starAppraiseView.sd_layout
    .leftEqualToView(self.nameLabel)
    .topSpaceToView(self.nameLabel, 10)
    .widthIs(100)
    .heightIs(20);
    
    self.saleLabel.sd_layout
    .leftEqualToView(self.nameLabel)
    .topSpaceToView(self.starAppraiseView, 10)
    .widthIs(100)
    .heightIs(20);
    
  
    
   
    
    /** cell 自适应第一步 */
    [self setupAutoHeightWithBottomView:self.saleLabel bottomMargin:10];
    
}

@end
